Changes spatial activity across the daily cycle

gam_fox_sp <- bam(fox ~ t2(x, y, hour, d = c(2, 1), bs = c("ds", "cc"), k = c(80, 8), m = c(1, 0.5), full = TRUE) +
                         s(foxbaits, bs = "tp", k = 4) + 
                         s(station, bs = "re") +  
                         offset(log(survey_duration)), 
                 data = records, family = nb, knots = list(hour = c(0, 23)), nthreads = 3, discrete = TRUE)
summary(gam_fox_sp)
## 
## Family: Negative Binomial(0.864) 
## Link function: log 
## 
## Formula:
## fox ~ t2(x, y, hour, d = c(2, 1), bs = c("ds", "cc"), k = c(80, 
##     8), m = c(1, 0.5), full = TRUE) + s(foxbaits, bs = "tp", 
##     k = 4) + s(station, bs = "re") + offset(log(survey_duration))
## 
## Parametric coefficients:
##             Estimate Std. Error t value            Pr(>|t|)    
## (Intercept)  -8.3843     0.1128  -74.32 <0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Approximate significance of smooth terms:
##                  edf   Ref.df      F              p-value    
## t2(x,y,hour)  79.400  559.000 21.843          0.000000469 ***
## s(foxbaits)    2.797    2.911 43.307 < 0.0000000000000002 ***
## s(station)   688.901 1231.000  3.029 < 0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## R-sq.(adj) =  0.117   Deviance explained = 35.2%
## fREML =  91177  Scale est. = 1         n = 87816
gam_cat_sp <- bam(cat ~ t2(x, y, hour, d = c(2, 1), bs = c("ds", "cc"), k = c(80, 8), m = c(1, 0.5), full = TRUE) +
                         s(station, bs = "re") +  
                         offset(log(survey_duration)), 
                 data = records, family = nb, knots = list(hour = c(0, 23)), nthreads = 3, discrete = TRUE)
summary(gam_cat_sp)
## 
## Family: Negative Binomial(2.188) 
## Link function: log 
## 
## Formula:
## cat ~ t2(x, y, hour, d = c(2, 1), bs = c("ds", "cc"), k = c(80, 
##     8), m = c(1, 0.5), full = TRUE) + s(station, bs = "re") + 
##     offset(log(survey_duration))
## 
## Parametric coefficients:
##             Estimate Std. Error t value            Pr(>|t|)    
## (Intercept) -8.07559    0.05587  -144.5 <0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Approximate significance of smooth terms:
##                 edf Ref.df     F             p-value    
## t2(x,y,hour)  57.16    559 7.375 <0.0000000000000002 ***
## s(station)   505.82   1231 1.240 <0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## R-sq.(adj) =  0.0772   Deviance explained = 23.2%
## fREML =  87198  Scale est. = 1         n = 87816

Spatial variation in the strength of diel patterns

## quartz_off_screen 
##                 2

Spatiotemporal activity across vegetation types

gam_fox_veg <- bam(fox ~ s(hour, bs = "cc", k = 8) +   
                         s(hour, vegetation_group, bs = "fs", xt = list(bs = "cc"), k = 8) + 
                         s(foxbaits, region, bs = "fs", xt = list(bs = "tp"), k = 4) + 
                         s(region, bs = "re") +  
                         s(station, bs = "re") +  
                         offset(log(survey_duration)), 
                   data = records, family = nb, knots = list(hour = c(0, 23)), nthreads = 3, discrete = TRUE)
      
summary(gam_fox_veg)
## 
## Family: Negative Binomial(0.853) 
## Link function: log 
## 
## Formula:
## fox ~ s(hour, bs = "cc", k = 8) + s(hour, vegetation_group, bs = "fs", 
##     xt = list(bs = "cc"), k = 8) + s(foxbaits, region, bs = "fs", 
##     xt = list(bs = "tp"), k = 4) + s(region, bs = "re") + s(station, 
##     bs = "re") + offset(log(survey_duration))
## 
## Parametric coefficients:
##             Estimate Std. Error t value            Pr(>|t|)    
## (Intercept)  -8.1858     0.2131  -38.41 <0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Approximate significance of smooth terms:
##                                  edf Ref.df        F              p-value    
## s(hour)                    5.5109203      6   12.876 < 0.0000000000000002 ***
## s(hour,vegetation_group)  22.4582536     48   76.599             0.000811 ***
## s(foxbaits,region)         5.4572356      7 1427.193 < 0.0000000000000002 ***
## s(region)                  0.0002997      1    0.000             0.933369    
## s(station)               732.9321817   1231    3.508 < 0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## R-sq.(adj) =  0.116   Deviance explained =   35%
## fREML =  91367  Scale est. = 1         n = 88008
gam_cat_veg <- bam(cat ~ s(hour, bs = "cc", k = 8) +   
                         s(hour, vegetation_group, bs = "fs", xt = list(bs = "cc"), k = 8) +  
                         s(region, bs = "re") +  
                         s(station, bs = "re") +  
                         offset(log(survey_duration)), 
                   data = records, family = nb, knots = list(hour = c(0, 23)), nthreads = 3, discrete = TRUE)
                 
summary(gam_cat_veg)
## 
## Family: Negative Binomial(2.17) 
## Link function: log 
## 
## Formula:
## cat ~ s(hour, bs = "cc", k = 8) + s(hour, vegetation_group, bs = "fs", 
##     xt = list(bs = "cc"), k = 8) + s(region, bs = "re") + s(station, 
##     bs = "re") + offset(log(survey_duration))
## 
## Parametric coefficients:
##             Estimate Std. Error t value            Pr(>|t|)    
## (Intercept)  -7.9475     0.1973  -40.28 <0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Approximate significance of smooth terms:
##                                  edf Ref.df      F             p-value    
## s(hour)                    4.6360650      6  5.202 <0.0000000000000002 ***
## s(hour,vegetation_group)  16.8351163     48 53.704 <0.0000000000000002 ***
## s(region)                  0.0001419      1  0.000               0.662    
## s(station)               545.3729969   1231  1.561 <0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## R-sq.(adj) =  0.0769   Deviance explained =   23%
## fREML =  87388  Scale est. = 1         n = 88008
## quartz_off_screen 
##                 2
## quartz_off_screen 
##                 2

Spatiotemporal activity in response to apex predator threat

gam_cat_fox <- bam(cat ~ habitat_type + t2(hour, fox_count_adj, by = habitat_type, bs = c("cc", "ts"), k = c(8, 5), full = TRUE) +  
                    s(longitude, latitude, bs = "ds",  m = c(1, 0.5), k = 200) +
                    s(station, bs = "re") +  
                    offset(log(survey_duration)), 
                  data = records, family = nb, knots = list(hour = c(0, 23)), nthreads = 3, discrete = TRUE)

summary(gam_cat_fox)
## 
## Family: Negative Binomial(2.284) 
## Link function: log 
## 
## Formula:
## cat ~ habitat_type + t2(hour, fox_count_adj, by = habitat_type, 
##     bs = c("cc", "ts"), k = c(8, 5), full = TRUE) + s(longitude, 
##     latitude, bs = "ds", m = c(1, 0.5), k = 200) + s(station, 
##     bs = "re") + offset(log(survey_duration))
## 
## Parametric coefficients:
##                       Estimate Std. Error t value      Pr(>|t|)    
## (Intercept)            -8.1530     1.3414  -6.078 0.00000000122 ***
## habitat_typedry_otway  -0.0834     2.3361  -0.036         0.972    
## habitat_typewet_otway   0.2910     2.3498   0.124         0.901    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Approximate significance of smooth terms:
##                                                    edf Ref.df     F
## t2(hour,fox_count_adj):habitat_typedry_glenelg   8.907     34 1.995
## t2(hour,fox_count_adj):habitat_typedry_otway     3.860     34 0.404
## t2(hour,fox_count_adj):habitat_typewet_otway     7.990     34 2.602
## s(longitude,latitude)                           25.666    181 5.991
## s(station)                                     509.506   1229 1.249
##                                                             p-value    
## t2(hour,fox_count_adj):habitat_typedry_glenelg           0.00000575 ***
## t2(hour,fox_count_adj):habitat_typedry_otway                0.00267 ** 
## t2(hour,fox_count_adj):habitat_typewet_otway             0.00000409 ***
## s(longitude,latitude)                          < 0.0000000000000002 ***
## s(station)                                     < 0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## R-sq.(adj) =  0.0787   Deviance explained = 23.2%
## fREML =  87391  Scale est. = 1         n = 88008
## quartz_off_screen 
##                 2

Individual heterogeneity in diel activity

gam_cat_ind_o <- bam(cat ~ s(hour, bs = "cc", k = 8) +   
                           s(hour, individual, bs = "fs", xt = list(bs = "cc"), k = 8) +  
                           s(longitude, latitude, bs = "ds",  m = c(1, 0.5), k = 150) +
                           s(station, bs = "re") +  
                           offset(log(survey_duration)), 
                     data = gam_data_o, family = nb, knots = list(hour = c(0, 23)), nthreads = 3, discrete = TRUE)

summary(gam_cat_ind_o)
## 
## Family: Negative Binomial(0.037) 
## Link function: log 
## 
## Formula:
## cat ~ s(hour, bs = "cc", k = 8) + s(hour, individual, bs = "fs", 
##     xt = list(bs = "cc"), k = 8) + s(longitude, latitude, bs = "ds", 
##     m = c(1, 0.5), k = 150) + s(station, bs = "re") + offset(log(survey_duration))
## 
## Parametric coefficients:
##             Estimate Std. Error t value            Pr(>|t|)    
## (Intercept) -12.7804     0.1356  -94.28 <0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Approximate significance of smooth terms:
##                          edf Ref.df     F              p-value    
## s(hour)                 2.10      6 1.362              0.00287 ** 
## s(hour,individual)     89.73    657 0.792 < 0.0000000000000002 ***
## s(longitude,latitude)  12.13    149 1.940              0.06276 .  
## s(station)            109.47    194 1.778 < 0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## R-sq.(adj) =  0.00379   Deviance explained = 23.8%
## fREML = 1.066e+06  Scale est. = 1         n = 1157328
gam_cat_ind_g <- bam(cat ~ s(hour, bs = "cc", k = 8) +   
                           s(hour, individual, bs = "fs", xt = list(bs = "cc"), k = 8) +  
                           s(longitude, latitude, bs = "ds",  m = c(1, 0.5), k = 150) +
                           offset(log(survey_duration)), 
                     data = gam_data_g, family = nb, knots = list(hour = c(0, 23)), nthreads = 3, discrete = TRUE)

summary(gam_cat_ind_g)
## 
## Family: Negative Binomial(0.018) 
## Link function: log 
## 
## Formula:
## cat ~ s(hour, bs = "cc", k = 8) + s(hour, individual, bs = "fs", 
##     xt = list(bs = "cc"), k = 8) + s(longitude, latitude, bs = "ds", 
##     m = c(1, 0.5), k = 150) + offset(log(survey_duration))
## 
## Parametric coefficients:
##             Estimate Std. Error t value            Pr(>|t|)    
## (Intercept) -12.5420     0.1348  -93.02 <0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Approximate significance of smooth terms:
##                            edf Ref.df     F              p-value    
## s(hour)                0.05533      6 0.009                0.256    
## s(hour,individual)    34.37424    272 0.224           0.00000305 ***
## s(longitude,latitude) 37.43878    149 0.626 < 0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## R-sq.(adj) =  0.000974   Deviance explained = 18.1%
## fREML = 3.6617e+05  Scale est. = 1         n = 397800
## quartz_off_screen 
##                 2
## quartz_off_screen 
##                 2

Session information

R version 3.6.3 (2020-02-29)

Platform: x86_64-apple-darwin15.6.0 (64-bit)

locale: en_AU.UTF-8||en_AU.UTF-8||en_AU.UTF-8||C||en_AU.UTF-8||en_AU.UTF-8

attached base packages: stats, graphics, grDevices, utils, datasets, methods and base

other attached packages: pander(v.0.6.3), activity(v.1.3.1), maptools(v.1.1-1), stringr(v.1.4.0), lubridate(v.1.7.10), reshape2(v.1.4.3), sf(v.0.9-6), sp(v.1.4-5), chron(v.2.3-56), gratia(v.0.6.0), viridis(v.0.5.1), viridisLite(v.0.4.0), ggpubr(v.0.4.0), patchwork(v.1.0.1), gganimate(v.1.0.7), ggplot2(v.3.3.3), mgcv(v.1.8-33), nlme(v.3.1-144) and dplyr(v.1.0.2)

loaded via a namespace (and not attached): progress(v.1.2.2), tools(v.3.6.3), backports(v.1.2.1), bslib(v.0.2.5.1), utf8(v.1.2.2), rgdal(v.1.4-7), R6(v.2.5.1), KernSmooth(v.2.23-16), DBI(v.1.1.1), colorspace(v.2.0-2), withr(v.2.4.2), tidyselect(v.1.1.0), gridExtra(v.2.3), prettyunits(v.1.1.1), curl(v.4.3.2), compiler(v.3.6.3), labeling(v.0.4.2), sass(v.0.4.0), scales(v.1.1.1), classInt(v.0.4-3), mvnfast(v.0.2.5), digest(v.0.6.27), foreign(v.0.8-75), rmarkdown(v.2.10), rio(v.0.5.27), pkgconfig(v.2.0.3), htmltools(v.0.5.2), highr(v.0.9), fastmap(v.1.1.0), rlang(v.0.4.11), readxl(v.1.3.1), jquerylib(v.0.1.4), farver(v.2.1.0), generics(v.0.1.0), jsonlite(v.1.7.2), zip(v.2.1.1), car(v.3.0-11), magrittr(v.2.0.1), Matrix(v.1.2-18), Rcpp(v.1.0.7), munsell(v.0.5.0), fansi(v.0.5.0), abind(v.1.4-5), lifecycle(v.1.0.0), stringi(v.1.7.4), yaml(v.2.2.1), carData(v.3.0-3), plyr(v.1.8.6), grid(v.3.6.3), forcats(v.0.5.0), crayon(v.1.4.1), lattice(v.0.20-38), cowplot(v.1.0.0), haven(v.2.2.0), splines(v.3.6.3), hms(v.0.5.2), knitr(v.1.33), pillar(v.1.6.2), ggsignif(v.0.6.2), glue(v.1.4.2), evaluate(v.0.14), data.table(v.1.12.6), gifski(v.0.8.6), vctrs(v.0.3.8), tweenr(v.1.0.1), cellranger(v.1.1.0), gtable(v.0.3.0), purrr(v.0.3.4), tidyr(v.1.0.0), xfun(v.0.25), openxlsx(v.4.2.4), broom(v.0.7.9), e1071(v.1.7-2), rstatix(v.0.7.0), class(v.7.3-15), tibble(v.3.1.4), units(v.0.6-5) and ellipsis(v.0.3.2)